<?php
namespace Orm\WinningLog;

class WinningLogModel extends \Base\BaseOrmModel{

    function __construct()
    {
        parent::__construct();
        $this->table = 't_winning_log';
    }

    /**
     * @param $user_id
     * @return array
     */
    public function getWinningListByUserId($user_id,$offset,$size){
        $re = array();
        $sql = "SELECT
                    a.*,b.link_url,c.`status`
                FROM
                    t_winning_log a
                LEFT JOIN t_coupon_type b ON a.coupon_type = b.id
                LEFT JOIN t_coupon c ON a.coupon_id = c.id
                WHERE
                 a.is_del = 0 AND  a.type = 0 AND a.user_id = {$user_id} ORDER BY id DESC";
        $re['total'] = $this->_fetch($sql, 2);
        $sql .= " LIMIT " . $offset . "," . $size;
        $re['list'] = $this->_fetch($sql, 1);
        return $re;
    }
}